# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=doas
pkgver=6.8.2
pkgrel=8
pkgdesc="OpenBSD's temporary privilege escalation tool"
url="https://github.com/Duncaen/OpenDoas"
arch="all"
license="ISC"
makedepends="bison"
subpackages="$pkgname-doc"
install="$pkgname.post-upgrade"
source="$pkgname-$pkgver.tar.gz::https://github.com/Duncaen/OpenDoas/archive/v$pkgver.tar.gz
	configuration-directory.patch
	manpage-example-path.patch
	change-PATH.patch
	rowhammer.patch
	doas.conf
	"
builddir="$srcdir/OpenDoas-$pkgver"
options="$options suid"

# secfixes:
#   6.8-r1:
#     - CVE-2019-25016

build() {
	./configure \
		--prefix=/usr \
		--without-pam \
		--with-timestamp \
		--with-doas-confdir
	make
}

check() {
	# doas -v returns 1
	./doas -v || test $? = 1
}

package() {
	make install DESTDIR="$pkgdir"

	install -d -m 750 "$pkgdir"/etc/doas.d
	install -m 640 "$srcdir"/doas.conf -t "$pkgdir"/etc/

	install -D -m 644 "$srcdir"/doas.conf "$pkgdir"/usr/share/doc/$pkgname/doas.conf.example
}

sha512sums="
4a93ff477413c859ba2702e688fa4f83248fff85e61e12336838a1e9aa1a8d9963a9782e4bc5e58e8d04b86c2c8ceb6b235ae9d3b32b3e548a2514a43653137d  doas-6.8.2.tar.gz
efad2866d9d3e26266bdb37555453a436aa88ff4b8877b2ba01f7446ea095d998313aa566cafba30d426c79968d3d4a610dfbaa2e33735ab60f1283c9d9fa4ef  configuration-directory.patch
60efd196595bda2c4f036cd0080a8825a85fedcc7524c917304b342373863213b3c557b4336f1dab760f167fd8cc2a59b2e744d8a47ff8a8acebbe74b1328f4f  manpage-example-path.patch
31a87aced097ea1189c2162172788cd27b82af318db3476e1c143d3c87d99e2aa6350f63b81361d0a54482ba8dd0cfd10928ff6074a4c66248a1ec815a274f68  change-PATH.patch
c18e0e164606466c2e59b94c463f31c8d4ba7f050938114525a70855935655d0c690662de63358ca6854d3411a486d5a85aa247895b640c3b124c957ff325fe9  rowhammer.patch
215e20a7db1c14edc4596f8b879f0e628cb2a0e3c51d6c37ed7327e7db9d3f90ba896523b81fe371d5ae68145c88bfd7a2ecdd60452d3030130d04e10f2488f3  doas.conf
"
